package org.getOffer;

import java.util.Arrays;

/**
 * @Author yu
 * @Date 2021/6/8
 */
public class Practice05 {

    public static void main(String[] args) {

        int c=' ';
        System.out.println(c);

        String s = "We are happy.";

        System.out.println(replaceSpace(s));

    }

    public static String replaceSpace(String s) {

        if (s==null){
            return null;
        }

        char[] chars=s.toCharArray();
        StringBuilder stringBuilder=new StringBuilder();

        for (int i=0;i<chars.length;i++){
            if (chars[i]==' '){
                stringBuilder.append("%20");
            }else{
                stringBuilder.append(chars[i]);
            }
        }

        return stringBuilder.toString();

    }

}
